home *** CD-ROM | disk | FTP | other *** search
/ Erotic Games: Memory / Erotic Games: Memory.iso / mac / air_installers / AdobeAIR.exe / setup.swf / scripts / components / LocalizedText.as < prev    next >
Text File  |  2009-02-12  |  5KB  |  184 lines

  1. package components
  2. {
  3.    import flash.text.Font;
  4.    import mx.controls.Text;
  5.    import mx.events.PropertyChangeEvent;
  6.    import mx.styles.StyleManager;
  7.    
  8.    public class LocalizedText extends Text
  9.    {
  10.       
  11.       private static var fontArray:Array = Font.enumerateFonts(false);
  12.        
  13.       
  14.       private var isFontRetrieved:Boolean = false;
  15.       
  16.       private var defaultAppFontFamily:String;
  17.       
  18.       private var _resourceName:String;
  19.       
  20.       private var _resourceParams:Array;
  21.       
  22.       private var _bundleName:String;
  23.       
  24.       private var _useHTML:Boolean = false;
  25.       
  26.       private var cachedEmbeddedFont:Font;
  27.       
  28.       public function LocalizedText()
  29.       {
  30.          super();
  31.          this.selectable = false;
  32.       }
  33.       
  34.       private function set _143661260resourceParams(param1:Array) : void
  35.       {
  36.          trace(this.id + " set resourceName: " + this.resourceName);
  37.          this._resourceParams = param1;
  38.          invalidateProperties();
  39.       }
  40.       
  41.       [Bindable(event="propertyChange")]
  42.       public function set resourceName(param1:String) : void
  43.       {
  44.          var _loc2_:Object = this.resourceName;
  45.          if(_loc2_ !== param1)
  46.          {
  47.             this._384566343resourceName = param1;
  48.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"resourceName",_loc2_,param1));
  49.          }
  50.       }
  51.       
  52.       override protected function commitProperties() : void
  53.       {
  54.          if(this.resourceName)
  55.          {
  56.             if(this.useHTML)
  57.             {
  58.                htmlText = this.localizeText();
  59.             }
  60.             else
  61.             {
  62.                text = this.localizeText();
  63.             }
  64.          }
  65.          super.commitProperties();
  66.       }
  67.       
  68.       private function set _384566343resourceName(param1:String) : void
  69.       {
  70.          this._resourceName = param1;
  71.          invalidateProperties();
  72.       }
  73.       
  74.       private function set _1377046061bundleName(param1:String) : void
  75.       {
  76.          this._bundleName = param1;
  77.          invalidateProperties();
  78.       }
  79.       
  80.       protected function localizeText() : String
  81.       {
  82.          return LocalizationManager.getInstance().getString(this.resourceName,this.bundleName,this.resourceParams);
  83.       }
  84.       
  85.       override public function initialize() : void
  86.       {
  87.          super.initialize();
  88.       }
  89.       
  90.       [Bindable(event="propertyChange")]
  91.       public function set bundleName(param1:String) : void
  92.       {
  93.          var _loc2_:Object = this.bundleName;
  94.          if(_loc2_ !== param1)
  95.          {
  96.             this._1377046061bundleName = param1;
  97.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"bundleName",_loc2_,param1));
  98.          }
  99.       }
  100.       
  101.       [Bindable(event="propertyChange")]
  102.       public function set useHTML(param1:Boolean) : void
  103.       {
  104.          var _loc2_:Object = this.useHTML;
  105.          if(_loc2_ !== param1)
  106.          {
  107.             this._148395598useHTML = param1;
  108.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"useHTML",_loc2_,param1));
  109.          }
  110.       }
  111.       
  112.       protected function ensureGlyphs(param1:String) : void
  113.       {
  114.          var _loc2_:String = null;
  115.          var _loc3_:Font = null;
  116.          if(!this.isFontRetrieved)
  117.          {
  118.             this.isFontRetrieved = true;
  119.             _loc2_ = getStyle("fontFamily");
  120.             if(_loc2_.match(/,/))
  121.             {
  122.                return;
  123.             }
  124.             for each(_loc3_ in fontArray)
  125.             {
  126.                if(_loc3_.fontName == _loc2_)
  127.                {
  128.                   this.cachedEmbeddedFont = _loc3_;
  129.                   this.defaultAppFontFamily = StyleManager.getStyleDeclaration("Application").getStyle("fontFamily");
  130.                }
  131.             }
  132.          }
  133.          if(this.cachedEmbeddedFont)
  134.          {
  135.             if(!this.cachedEmbeddedFont.hasGlyphs(param1))
  136.             {
  137.                setStyle("fontFamily",this.defaultAppFontFamily);
  138.             }
  139.             else
  140.             {
  141.                setStyle("fontFamily",this.cachedEmbeddedFont.fontName);
  142.             }
  143.          }
  144.       }
  145.       
  146.       [Bindable(event="propertyChange")]
  147.       public function set resourceParams(param1:Array) : void
  148.       {
  149.          var _loc2_:Object = this.resourceParams;
  150.          if(_loc2_ !== param1)
  151.          {
  152.             this._143661260resourceParams = param1;
  153.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"resourceParams",_loc2_,param1));
  154.          }
  155.       }
  156.       
  157.       private function set _148395598useHTML(param1:Boolean) : void
  158.       {
  159.          this._useHTML = param1;
  160.          invalidateProperties();
  161.       }
  162.       
  163.       public function get useHTML() : Boolean
  164.       {
  165.          return this._useHTML;
  166.       }
  167.       
  168.       public function get resourceParams() : Array
  169.       {
  170.          return this._resourceParams;
  171.       }
  172.       
  173.       public function get resourceName() : String
  174.       {
  175.          return this._resourceName;
  176.       }
  177.       
  178.       public function get bundleName() : String
  179.       {
  180.          return this._bundleName;
  181.       }
  182.    }
  183. }
  184.